package me.ivenapp.gomoku;

import com.hjq.permissions.XXPermissions;
import me.ivenapp.gomoku.component.GomokuBoard;
import me.ivenapp.gomoku.slice.GomokuAbilitySlice;
import me.ivenapp.gomoku.slice.GomokuModeSlice;
import ohos.aafwk.content.Intent;

import ohos.bundle.AbilityInfo;
import ohos.global.configuration.Configuration;

public class GomokuAbility extends AbilityBase {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);

        setColorMode(Configuration.LIGHT_MODE);
        int gameMode = intent.getIntParam(GomokuBoard.PARAM_GAME_MODE, -1);
        if(gameMode == GomokuBoard.MODE_ONLINE) {
            super.setMainRoute(GomokuAbilitySlice.class.getName());
        } else {
            super.setMainRoute(GomokuModeSlice.class.getName());
        }

        setDisplayOrientation(AbilityInfo.DisplayOrientation.PORTRAIT);
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
        XXPermissions.addPermissionsForResult(this,
                requestCode, permissions, grantResults);
    }

    @Override
    protected void onBackground() {
        super.onBackground();
        setColorMode(MyApplication.getConfigColorMode());
    }
}
